package common

import "server/bitkop/app/constants"

func Success(data interface{}) map[string]interface{} {
	return map[string]interface{}{
		"code": 	constants.OK.GetCode(),
		"msg": 		constants.OK.GetMessage(),
		"data": 	data,
	}
}

func Error(code constants.MsgCode, msg ...string) map[string]interface{} {
	errorMsg := code.GetMessage()
	if len(msg) > 0 {
		errorMsg = msg[0]
	}
	return map[string]interface{}{
		"code": 	code.GetCode(),
		"msg": 		errorMsg,
	}
}

// K线图成功失败
func KlineSuccess(data interface{}) map[string]interface{} {
	return map[string]interface{}{
		"success": true,
		"data": map[string]interface{}{
			"lines": data,
		},
	}
}

func KlineError(message string) map[string]interface{} {
	return map[string]interface{}{
		"success": false,
		"message": message,
	}
}